package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.entity.Category;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Mapper
public interface CategoryMapper {
    List<Category> queryByCondition(Category category);

    @AutoFill(OperationType.INSERT)
    @Insert("insert into category " +
            "values (null,#{type},#{name},#{sort},#{status},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    void insert(Category category);

    @AutoFill(OperationType.UPDATE)
    void update(Category category);

    @Select("select * from category where id = #{id}")
    Category getById(Long id);

    @Delete("delete from category where id = #{id}")
    void delete(Long id);

    @Select("SELECT * from category where id = #{categoryId}")
    Category queryById(Long categoryId);
}
